
#include "EventManager.h"
#include "Render.h"

#include <SDL.h>

EventManager::EventManager() {
	//ctor
}

EventManager::~EventManager() {
	//dtor
}

void EventManager::manage(bool& done, ge::Render& render) {
	SDL_Event event;
	double step = 4;
	while (SDL_PollEvent(&event)) {
		switch (event.type) {
		case SDL_QUIT:

			done = true;
			std::cout << "quit requested\n";
			break;
		case SDL_KEYDOWN:
			switch (event.key.keysym.sym) {
			case SDLK_RIGHT:
				render.setXSpeed(step);
				break;
			case SDLK_LEFT:
				render.setXSpeed(-step);
				break;
			case SDLK_UP:
				render.setYSpeed(step);
				break;
			case SDLK_DOWN:
				render.setYSpeed(-step);
				break;
			default:
				break;
			}
			break;
		case SDL_KEYUP:
			switch (event.key.keysym.sym) {
			case SDLK_RIGHT:
				render.setXSpeed(0);
				break;
			case SDLK_LEFT:
				render.setXSpeed(0);
				break;
			case SDLK_UP:
				render.setYSpeed(0);
				break;
			case SDLK_DOWN:
				render.setYSpeed(0);
				break;
			default:
				break;
			}
			break;
		case SDL_MOUSEBUTTONUP:
			if (event.button.button == SDL_BUTTON_WHEELUP) {
				render.incrementZoom();
			} else if (event.button.button == SDL_BUTTON_WHEELDOWN) {
				render.decrementZoom();
			}
			break;
		default:
			break;
		}
	}
}
